%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% This file is part of the book
%%
%% Algorithmic Graph Theory
%% http://code.google.com/p/graphbook/
%%
%% Copyright (C) 2009--2013 Minh Van Nguyen <mvngu.name@gmail.com>
%%
%% See the file COPYING for copying conditions.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{algorithmic}[1]
%% input and output
\Require A list $L$ of $n > 1$ elements that can be ordered using the
  ``less than or equal to'' relation ``$\leq$''.
\Ensure The same list as $L$, but sorted in nondecreasing order.
%%
%% algorithm body
\For{$i \gets n, n - 1, \dots, 2$}
  \For{$j \gets 2, 3, \dots, i$}
    \If{$L[j-1] > L[j]$}
      \State swap the values of $L[j-1]$ and $L[j]$\label{alg:bubble_sort:swap_values}
    \EndIf
  \EndFor
\EndFor
\State \Return $L$
\end{algorithmic}
